/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
public:
    vector<int> postorder(Node* root) {
        vector<int> preOrder;
		if (!root)
		{
			return preOrder;
		}
		
		
		for (int i=0;i<root->children.size();i++)
		{
			auto ret=postorder(root->children[i]);
			for (auto retdata:ret)
			{
				preOrder.push_back(retdata);
			}
		}
        preOrder.push_back(root->val);
		return preOrder;

    }
};